#pragma once
#include <iostream>
#include <pthread.h>

class Mutex
{
public:
    Mutex(pthread_mutex_t *pmtx)
        : _pmtx(pmtx)
    {
    }

    void Lock()
    {
        pthread_mutex_lock(_pmtx);
    }

    void unLock()
    {
        pthread_mutex_unlock(_pmtx);
    }

private:
    pthread_mutex_t *_pmtx;
};

class lockGuard
{
public:
    lockGuard(pthread_mutex_t *pmtx)
        : _mutex(pmtx)
    {
        _mutex.Lock();
    }

    ~lockGuard()
    {
        _mutex.unLock();
    }

private:
    Mutex _mutex;
};